package com.rmb.userinfo.service.impl;

import com.rmb.mart.entity.invoice.InvoiceInformation;
import com.rmb.userinfo.dao.InvoiceAddressDao;
import com.rmb.mart.entity.invoice.InvoiceAddress;
import com.rmb.userinfo.service.InvoiceAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (InvoiceAddress)表服务实现类
 *
 * @author makejava
 * @since 2021-01-20 11:02:22
 */
@Service("invoiceAddressService")
public class InvoiceAddressServiceImpl implements InvoiceAddressService {
    @Resource
    private InvoiceAddressDao invoiceAddressDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public InvoiceAddress queryById(Long id) {
        return this.invoiceAddressDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<InvoiceAddress> queryAllByLimit(int offset, int limit) {
        return this.invoiceAddressDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param invoiceAddress 实例对象
     * @return 实例对象
     */
    @Override
    public InvoiceAddress insert(InvoiceAddress invoiceAddress) {
        this.invoiceAddressDao.insert(invoiceAddress);
        return invoiceAddress;
    }

    /**
     * 修改数据
     *
     * @param invoiceAddress 实例对象
     * @return 实例对象
     */
    @Override
    public InvoiceAddress update(InvoiceAddress invoiceAddress) {
        this.invoiceAddressDao.update(invoiceAddress);
        return this.queryById(invoiceAddress.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.invoiceAddressDao.deleteById(id) > 0;
    }

    /**
     * 查询发票地址所有信息
     * @return
     */
    @Override
    public List<InvoiceInformation> selectAll() {
        return invoiceAddressDao.selectAll();
    }
}